package org.cn.springcloudvv.cxf.controller;

import lombok.extern.slf4j.Slf4j;
import org.cn.springcloudvv.cxf.service.UserService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RestController;
import org.cn.springcloudvv.cxf.vo.User;

/**
 * <p><em>Created on 2021/12/1 5:44 下午</em></p>
 * @author fuzhongtang
 * @since 1.0.1
 */
@Slf4j
@RestController
public class UserController {

    private final Logger logger = LoggerFactory.getLogger(getClass());

    @Autowired
    private UserService userService;


    /**
     * 新增用户信息
     * @param user
     * @return
     */
    @PostMapping("/api/user/addUser")
    public User addUser(User user)
    {
        return userService.saveUser(user);
    }

    /**
     * 从mysql查询用户信息
     * @param user
     * @return
     */
    @PostMapping("/api/user/getUser")
    public User getUser(User user)
    {
        return userService.queryUserFromMysql(user);
    }
    @PostMapping("/health")
    public String health()
    {
        return "200";
    }
}
